package com.qianli.cashmama.trade.controller;

import com.fqgj.common.api.Response;
import com.fqgj.xjd.user.client.UserService;
import com.fqgj.xjd.user.client.response.User;
import com.qianli.cashmama.trade.client.trade.TradeApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2021/12/5
 * Time: 11:15 下午
 */

@Controller
@RequestMapping("/copy")
public class CopyController {



    @Autowired
    private TradeApplicationService tradeApplicationService;

    @Autowired
    private UserService userService;


    @RequestMapping("/unpaid/order/{mobile}")
    @ResponseBody
    public String ok22(@PathVariable String mobile) {
        Response<User> userByMobile = userService.getUserByMobile(mobile);
        if (userByMobile == null || userByMobile.getData() == null) {
            return "user not exist";
        }
        Response<Boolean> booleanResponse = tradeApplicationService.copyOldUnpaidOrders(mobile, userByMobile.getData().getUserCode(), "");
        return "trade,ok";
    }

}
